Fix ip_of to cope with interfaces with multiple addresses, courtesy of
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 8 Dec 2005 15:54:35 +0000 (15:54 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 8 Dec 2005 15:54:35 +0000 (15:54 +0000)
Adam Heath <doogie@brainfood.com>.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/examples/vif-common.sh

index 18a0b6c88e47e69a9e5d9ed6a749945b35d7f221..105a843900612fcfd71b661f09daf7a373e15842 100644 (file)
@@ -113,7 +113,7 @@ function handle_iptable()
 #
 function ip_of()
 {
-  ip addr show "$1" | sed -n 's/^.*inet \([0-9.]*\).*$/\1/p'
+  ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed 's,/.*,,'
 }